#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(){
        cout << "Point()" << endl;
    }

    //初始化列表中对数据成员进行初始化是严格的初始化
    //在函数体中对数据成员“初始化”实际是赋值操作
    //
    //数据成员的初始化顺序与其声明顺序一致
    Point(int x ,int y)
    : _ix(x)//int _ix = x;
    , _iy(y)//int _iy = y;
    {
        cout << "Point(int,int)" << endl;
    }

    Point(int x,int y,int z){
        //这种属于对数据成员赋值
        //int _ix;
        //_ix = x;
        _ix = x;
        _iy = y + z;
        cout << "Point(int*3)" << endl;
    }

    Point(int x);


    void setX(int x){
        _ix = x;
    }

    void setY(int y){
        _iy = y;
    }

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }
private:
    //c++11
    int _ix = 1;
    int _iy = 1;
};

Point::Point(int x)
: _ix(x)
, _iy(100)
{
    cout << "Point(int)" << endl;
}

void test2(){
    Point pt;
    Point pt2(1,2);
    Point pt3(3,4,5);
    Point pt4(10);
    cout << sizeof(Point) << endl;
    cout << sizeof(pt) << endl;
    cout << sizeof(pt2) << endl;
    cout << sizeof(pt3) << endl;
    cout << sizeof(pt4) << endl;
}

void test0(){
    int num;
    num = 1;

    Point pt;//自动调用构造函数
    pt.print();
    pt.setX(1);
    pt.setY(2);
}

void test1(){
    int num = 10;
    Point pt(5,6);
    pt.print();

    Point pt2(4,7,9);
    pt2.print();

    Point pt3(10);
    pt3.print();
}

int main(void){
    test2();
    return 0;
}
